package cn.wuxing.mediation.web.controller.contradiction;

import cn.wuxing.mediation.common.core.controller.BaseController;
import cn.wuxing.mediation.common.core.page.PageDomain;
import cn.wuxing.mediation.common.core.page.TableDataInfo;
import cn.wuxing.mediation.common.core.page.TableSupport;
import cn.wuxing.mediation.common.utils.poi.ExcelUtil;
import cn.wuxing.mediation.system.domain.MdjfReq;
import cn.wuxing.mediation.system.domain.StgMplcHzZzEventDiWxq;
import cn.wuxing.mediation.system.domain.vo.MdjfListVo;
import cn.wuxing.mediation.system.service.IMdkfListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(tags = "矛盾纠纷")
//@RequestMapping("/cm/mdjf")
@RestController
public class MdkfListController extends BaseController {

    @Autowired
    private IMdkfListService dkfListService;

    @ApiOperation(value = "全量查询", notes = "参数说明")
    @GetMapping("list")
    public TableDataInfo list(MdjfReq req){
        startPage();
        List<MdjfListVo> mdjfListVos = dkfListService.queryList(req);
        return getDataTable(mdjfListVos);
    }

    /**
     * 导出
     * @param response
     * @param req
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, MdjfReq req)
    {
        if(req.getIds()==null||req.getIds().size()==0){//如果没勾选,就导出当前分页
            PageDomain pageDomain = TableSupport.buildPageRequest();
            Integer pageNum = pageDomain.getPageNum();
            Integer pageSize = pageDomain.getPageSize();
            req.setCurrentPage((pageNum-1)*pageSize);
            req.setCurrentPageSize(pageSize);
        }
        List<MdjfListVo> list = dkfListService.queryListAll(req);
        ExcelUtil<MdjfListVo> util = new ExcelUtil<MdjfListVo>(MdjfListVo.class);
        util.exportExcel(response, list, "矛盾纠纷全量库信息数据");
    }
}
